#!/usr/bin/env bash

containerName='nginx'

exist=$(docker inspect --format '{{.State.Running}}' ${containerName})

if [ "${exist}" != "true"  ]; then
    docker restart ${containerName}
    sleep 5
    counter=$(docker ps --format='{{.Names}}' | grep -c nginx)
    if [ "${counter}" = "0" ]; then
        systemctl stop keepalived.service
    fi
fi